package zust.javaee.entity;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by liy on 2016/12/18.
 */
@Entity
@Table(name = "tmember")
public class Tmember {

    private Integer id;
    private Tcorporation tcorporation;
    private Tplayer tplayer;
    private Short level;   //队员重要等级，默认3（满5）
    private Date joinTime;
    private String position;  //职位
    private Integer demeritTimes;  //记过次数
    private Integer score;  //该成员在此社团所获取的分数
    private Short status;  //在位；主动退出；被动提出

    private Set<Tcorporation> tcorporations = new HashSet<Tcorporation>(0);
    private Set<Tactivity> tactivities = new HashSet<Tactivity>(0);
    private Set<Tannouncement> tannouncements = new HashSet<Tannouncement>(0);
    private Set<TsignupActivityForm> tsignupActivityForms = new HashSet<TsignupActivityForm>(0);

    public Tmember() {
    }

    @Id
    @GeneratedValue
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "corporation_id")
    public Tcorporation getTcorporation() {
        return tcorporation;
    }

    public void setTcorporation(Tcorporation tcorporation) {
        this.tcorporation = tcorporation;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "player_id")
    public Tplayer getTplayer() {
        return tplayer;
    }

    public void setTplayer(Tplayer tplayer) {
        this.tplayer = tplayer;
    }

    @Column(name = "level")
    public Short getLevel() {
        return level;
    }

    public void setLevel(Short level) {
        this.level = level;
    }

    @Column(name = "join_time")
    public Date getJoinTime() {
        return joinTime;
    }

    public void setJoinTime(Date joinTime) {
        this.joinTime = joinTime;
    }

    @Column(name = "position")
    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    @Column(name = "demerit_times")
    public Integer getDemeritTimes() {
        return demeritTimes;
    }

    public void setDemeritTimes(Integer demeritTimes) {
        this.demeritTimes = demeritTimes;
    }

    @Column(name = "score")
    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    @Column(name = "status")
    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "principal")
    public Set<Tcorporation> getTcorporations() {
        return tcorporations;
    }

    public void setTcorporations(Set<Tcorporation> tcorporations) {
        this.tcorporations = tcorporations;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "principal")
    public Set<Tactivity> getTactivities() {
        return tactivities;
    }

    public void setTactivities(Set<Tactivity> tactivities) {
        this.tactivities = tactivities;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "principal")
    public Set<Tannouncement> getTannouncements() {
        return tannouncements;
    }

    public void setTannouncements(Set<Tannouncement> tannouncements) {
        this.tannouncements = tannouncements;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tmember")
    public Set<TsignupActivityForm> getTsignupActivityForms() {
        return tsignupActivityForms;
    }

    public void setTsignupActivityForms(Set<TsignupActivityForm> tsignupActivityForms) {
        this.tsignupActivityForms = tsignupActivityForms;
    }
}
